<template>
    <div>
     <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="admin_name"
        label="用户名"
        >
      </el-table-column>
      <el-table-column
        prop="log_info"
        label="行为"
        width="180">
      </el-table-column>
      <el-table-column
        prop="log_url"
        label="Url">
      </el-table-column>
         <el-table-column
        prop="log_ip"
        label="IP">
      </el-table-column>
         <el-table-column
        prop="address"
        label="操作">
        <template slot-scope="{row}">
                    <el-dropdown 
                    trigger="click"
                     slot="dropdown"
                    >
                     <span class="el-dropdown-link">
                        <span class="imghover"></span>
                     </span>
                     <el-dropdown-menu slot="dropdown">
                       <div  @click="rizhibtn(row)" class="itemcss">详情</div>
                       <div  @click="deletebtn(row)" class="itemcss">删除</div>
                     </el-dropdown-menu>
                   </el-dropdown>
        </template>  
      </el-table-column>
    </el-table>
     <rizhiinfo :showrizhiinfo.sync="showrizhiinfo"></rizhiinfo>
    </div>
</template>
<script>
import {  getrizhilist } from "@/api/permission/index";
import  {mapState,mapMutations} from "vuex"
import rizhiinfo from "../componens/rizhiinfo"
export default {
    data(){
        return {
            showrizhiinfo:false,//添加管理员弹窗
            tableData:[{}],
            fromrizhi:{
                admin_id:this.userInfo,
                page:0,
                limit:10
            },
        }
    },
    computed:{
        ...mapState(['userInfo'])
    },
    methods:{
        ...mapMutations(['handelacaouoinfo']),
        //获取管理员日志
        async getrizhi(){
            this.fromrizhi.admin_id = this.userInfo.admin_id
            //获取日志列表
            const data = await getrizhilist(this.fromrizhi)
            if (data.code == 1) {
                  //操作日志存入vuex
                  this.handelacaouoinfo(data.data[0])
                  this.tableData = data.data
                  this.$message({
                  message: data.msg,
                  type: 'success'
             });
            }
        },
        // 查看详情
        async rizhibtn(row){
          this.showrizhiinfo = true
        },
        // 删除日志
        deletebtn(){
           this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        })
        }
    },
    components:{
        rizhiinfo
    },
    mounted(){
        this.getrizhi()
    }
    
}
</script>
<style lang="less" scoped>

</style>